<template>
  <div class="location">
    <span class="city" @click="goCitySelect">
        {{ selectCity.cityName }}
    </span>
    <div class="position" @click="getLocation">
        <span>{{ location }}</span>
        <img src="@/assets/img/home/icon_location.png" alt="">
    </div>
  </div>
  <HomeDate></HomeDate>
  <HomeSearch></HomeSearch>
</template>

<script setup>
    import {ref} from "vue"
    import {useRouter} from "vue-router"
    import getLocation from "@/utils/getLocation";
    import useCityStore from "@/stores/modules/city";
    import { storeToRefs } from "pinia";
    import HomeDate from "./HomeDate.vue";
    import HomeSearch from "./HomeSearch.vue";
    
    
    const router = useRouter()
    const cityStore = useCityStore()
    const {selectCity} = storeToRefs(cityStore)

    const location = ref("我的位置")
    getLocation(location)

    function goCitySelect(){
        router.push("/city")
    }
    
</script>

<style lang="less" scoped>
    .location {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding:  20px;

        .position {
            display: flex;
            align-items: center;
            font-size: 12px;

            img {
                padding: 3px;
                width: 15px;
                vertical-align:top;
            }
        }
    }
</style>